package com.atguigu.gmall.all.controller;

import com.atguigu.gmall.model.order.OrderInfo;
import com.atguigu.gmall.order.client.OrderFeignClient;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;

import javax.servlet.http.HttpServletRequest;

/**
 * @author Fxz
 * @version 1.0
 * @date 2022-02-21 15:55
 */
@Controller
@RequiredArgsConstructor
public class PaymentController {

	private final OrderFeignClient orderFeignClient;

	@GetMapping("pay.html")
	public String pay(HttpServletRequest request) {
		String orderId = request.getParameter("orderId");
		OrderInfo orderInfo = orderFeignClient.getOrderInfo(Long.valueOf(orderId));
		request.setAttribute("orderInfo", orderInfo);

		return "payment/pay";
	}

	@GetMapping("/pay/success.html")
	public String paySuccess() {
		return "payment/success";
	}

}
